//
//  BoyTableViewCell.m
//  自定义cell练习
//
//  Created by dllo on 15/11/26.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "BoyTableViewCell.h"

@implementation BoyTableViewCell

- (void)dealloc
{
    [_label release];
    [super dealloc];
}

+ (CGFloat)heightWithStr:(NSString *)str
{
    CGRect frame = [str boundingRectWithSize:CGSizeMake(300, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:18.0] forKey:NSFontAttributeName] context:nil];
    return frame.size.height;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat height = [[self class] heightWithStr:self.label.text];

    CGRect frameL = self.label.frame;
    frameL.size.height = height;
    self.label.frame = frameL;




}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self credateSubviews];
    }
    return self;
}

- (void)credateSubviews
{
    self.backgroundColor = [UIColor yellowColor];
    
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
    self.label.text = @"王宁";
    self.label.numberOfLines = 0;
    self.label.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:self.label];
    [_label release];

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
